@extends('admin.layout')
@section('body')
    <!-- 正文开始 -->
    <div class="layui-fluid">
        <div class="layui-card">
            <div class="layui-card-body">
                <!-- 表格工具栏 -->
                <form class="layui-form toolbar" id="formSearch">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">日期范围::</label>
                            <div class="layui-input-inline">
                                 <input name="date_range" autocomplete="off" id="txtDateRange" class="layui-input"/>
                            </div>
                        </div>
                        <div class="layui-inline">&emsp;
                            <button class="layui-btn icon-btn" lay-filter="searchForm" lay-submit>
                                <i class="iconfont icon-ic_search"></i>@lang('common.search')
                            </button>
                        </div>
                    </div>
                </form>
                <!-- 数据表格 -->
                <table id="adminTable" lay-filter="adminTable"></table>
            </div>
        </div>
    </div>
@stop
@push('script')
    <script>
layui.use(['table','form','laydate'], function(){
  var table = layui.table,form=layui.form; 
  layui.laydate.render({
                elem: '#txtDateRange'
                , range: '~' //或 range: '~' 来自定义分割字符
            });
  //第一个实例
  let tableIns=table.render({
    elem: '#adminTable'
    ,height: 'auto' 
    ,url: '{{admin_url($baseRoute.'pager_promotion')}}' //数据接口
    ,page: false //开启分页
    ,cols: [[ 
      {field: 'day',title: '日期'}
      ,{field: 'money',title: '消费'} 
      ,{field: 'zhanshi',title: '展示'} 
      ,{ title: '点击',colspan:3} 
      ,{ title: '总对话',colspan:3} 
      ,{ title: '有效对话',colspan:3} 
      ,{ title: '套电',colspan:3} 
      ,{ title: '预约',colspan:3} 
      ,{ title: '到诊',colspan:3} 
      ,{ title: '转化率'} 
    ],[
    	{ title: '-',colspan:3}
    	,{field: 'dianji', title: '点击'}
    	,{title: '点击率',templet:function(d){return (d.dianji/d.zhanshi*100).toFixed(2)+'%';}}
    	,{templet:function(d){return (d.money/d.dianji).toFixed(2);}, title: '成本'}
    	,{field: 'duihua', title: '对话'}
    	,{title: '对话率',templet:function(d){return (d.duihua/d.dianji*100).toFixed(2)+'%';}}
    	,{templet:function(d){return (d.money/d.duihua).toFixed(2);},title: '成本'}
    	,{title: '对话',field:'dj'}
    	,{title: '对话率',templet:function(d){return (d.dj/d.duihua*100).toFixed(2)+'%';}}
    	,{templet:function(d){return (d.money/d.dj).toFixed(2);},title: '成本'}
    	,{title: '套电',field:'td'}
    	,{title: '套电率',templet:function(d){return (d.td/d.dj*100).toFixed(2)+'%';}}
    	,{templet:function(d){return (d.money/d.td).toFixed(2);},title: '成本'}
    	,{title: '预约',field:'yy'}
    	,{title: '预约率',templet:function(d){return (d.yy/d.dj*100).toFixed(2)+'%';}}
    	,{templet:function(d){return (d.money/d.yy).toFixed(2);},title: '成本'}
    	,{title: '到诊',field:'dz'}
    	,{title: '到诊率',templet:function(d){return (d.dz/d.yy*100).toFixed(2)+'%';}}
    	,{templet:function(d){return (d.money/d.dz).toFixed(2);},title: '成本'}
    	,{templet:function(d){return (d.dj/d.dz).toFixed(2);},title: '有效对话/到诊'}
    ]]
  });
  form.on('submit(searchForm)', function(data){
  	searchWhere = data.field;
  	 table.reload('adminTable', {
	  url: '{{admin_url($baseRoute.'pager_promotion')}}'
	  ,where: searchWhere  
	 
	});
     return false; 
  });
});
 
</script> 	
@endpush
